package com.city.service.pub.impl;

import com.city.domain.pub.PubArticle;
import com.city.repository.pub.PubArticleRepository;
import com.city.service.pub.PubArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @deprecation: 公共文章
 * @dmail: 398521613@qq.com
 * @author: L-H
 * @date: 2018-07-18 13:14
 */
@Service
public class PubArticleServiceImpl implements PubArticleService {
    @Autowired
    private PubArticleRepository pubArticleRepository;

    /**
     **
      *@author:WY
      *@date: 2018/7/23 19:36
      *@description:通过实时动态查询
     *
     * @return
     */
    @Override
    public List<PubArticle> findPubArticlesByPre(String type) {
        return pubArticleRepository.findPubArticlesByPre(type);
    }

    @Override
    public List<PubArticle> findAll() {
        return pubArticleRepository.findAll();
    }

    @Override
    public PubArticle findById(int id) {
        return pubArticleRepository.findPubArticleById(id);
    }

    @Override
    public List<PubArticle> findPubArticlesByType(String type) {
        return pubArticleRepository.findPubArticlesByType(type);
    }

    @Override
    public long count() {
        return pubArticleRepository.count();
    }

    @Override
    public List<PubArticle> findPubArticleLimit(Integer page, Integer limit) {
        return pubArticleRepository.findPubArticleLimit((page-1)*limit,limit);
    }

    @Override
    public void deleteArticle(int id) {
        pubArticleRepository.delete(id);
    }

    @Override
    public List<PubArticle> findByTypeName(String typeName, Integer page, Integer limit) {
        return pubArticleRepository.findByTypeName(typeName,(page-1)*limit,limit);
    }

    @Override
    public List<PubArticle> findByTheSource(String theSource, Integer page, Integer limit) {
        return pubArticleRepository.findByTheSource(theSource,(page-1)*limit,limit);
    }

    @Override
    public List<PubArticle> findByTypeNameAndTheSource(String typeName, String theSource, Integer page, Integer limit) {
        return pubArticleRepository.findByTypeNameAndTheSource(typeName,theSource,(page-1)*limit,limit);
    }

    @Override
    public long countTypeName(String typeName) {
        return pubArticleRepository.countTypeName(typeName);
    }

    @Override
    public long countTheSource(String theSource) {
        return pubArticleRepository.countTheSource(theSource);
    }

    @Override
    public long countTypeNameAndTheSource(String typeName, String theSource) {
        return pubArticleRepository.countTypeNameAndTheSource(typeName,theSource);
    }
}
